<%@page import="java.util.List"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.Register"%>
<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<Register>registers=(List<Register>)request.getAttribute("register");
    Integer ids=(Integer)request.getAttribute("id");
    %>
<table class="result-tab" width="100%">
                        <tr>
                            <th>排序</th>
                            <th>ID</th>
                            <th>名字</th>
                            <th>性别</th>
                            <th>电话</th>
                            <th>身份证号</th>
                            <th>开始时间</th>
                            <th>退房时间</th>
                        </tr>
                        <%
                        if(registers!=null){
                        	DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                         for(int i=0;i<registers.size();i++){
                        	 Register register=registers.get(i);
                        	 String startTime=df.format(register.getStartTime());
                         	 String endTime=df.format(register.getEndTime());
                         	 %>
                         	  <tr>
                            <td><%=i+1 %></td>
                            <td><%=register.getId() %></td>
                            <td><%=register.getName() %></td>
                            <td><span class="gender"><%=register.getGender() %></span></td>
                            <td><%=register.getTelephoneNumber() %></td>
                            <td><%=register.getIdCard() %></td>
                            <td><%=startTime %></td>
                            <td><%=endTime %></td>
                        </tr>
                         	 <%
                         }   
                        }
                        %>
                    </table>
                    </div>
                    <div class="qwe">
                     <%
                     Pager pager=(Pager)request.getAttribute("pager");
                     if(pager!=null){
                     	 int start= 1;
                          int end =pager.getPageCount();
                          if(pager.getPageCount()>5){
                         	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                         	 end=start+4;
                         	 if(end>pager.getPageCount()){
                         		 end=pager.getPageCount();
                         		 start=end-4;
                         	 }
                          }
                          %>
                          [<a class="ok" href="javascript:void(0)">上一页</a>]
                          <%
                     	for(int i=start;i<=end;i++){
                     		if(pager.getPageNo()!=i){
                     		%>
                     		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                     		<%
                     	}else{
                     		%>
                     		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                     		<%
                     	}
                     }
                          %>
                          [<a class="no" href="javascript:void(0)">下一页</a>]
                          <%
                     }
                     %>
                    </div>
                    <script>
					$(".aaa").css("color","red");
					</script>
					<style>
					.qwe{
						text-align:center;
						}
						.aaa{
						text-align:center;
						}
					</style>
					 <script>
                    $(function(){
                    	$(".no").click(function(){
                    		/* $(".number").css("color","black");
                    		$(this).css("color","red"); */
                    		var content=<%=pager.getPageNo()%>;
                    		if(content<<%=pager.getPageCount()%>){
                    			content++;
                    		}
                    		$.ajax({
                    			url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
                    				data:{pageNo:content},
                    					success:function(msg){
                    						$("#pagediv").html(msg);
                    					}
                    		})
                    	})
                    $(".ok").click(function(){
                    /* $(".number").css("color","black");
                    $(this).css("color","red"); */
                    var content=<%=pager.getPageNo()%>;
                    if(content>1){
                    	content--;
                    }
                    $.ajax({
                    url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
                    data:{pageNo:content},
                    success:function(msg){
                    	$("#pagediv").html(msg);
                    }
                    })
                    })
                    	$(".number").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				console.log(1);
                   				$("#pagediv").html(msg);
                   			}
                   		})
                   	})
                   	$(".aaa").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				$("#pagediv").html(msg);
                   			}
                   		})
                   	})
	$(".gender").each(function(){
		var check=$(this).html();
		
		if(check=="false"){
			$(this).html("女");
		}else if(check=="true"){
			$(this).html("男");
		} 
	})
	/* $(".breakfast").each(function(){
		var check=$(this).html();
		
		if(check=="false"){
			$(this).html("不需要");
		}else if(check=="true"){
			$(this).html("需要");
		} 
	}) */
                    })
                    </script> 